package com.example.zm_fanjiantao.web.controller;

import com.example.zm_fanjiantao.mapper.UserMapper;
import com.example.zm_fanjiantao.web.model.User;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@RequestMapping("/user")
@RestController
public class Users{
    @Resource
    private UserMapper userMapper;

    @GetMapping("/list")
    public Map<String,Object> list(){
       Map data = new HashMap();
       data.put("code",0);
       data.put("data",userMapper.userList());
       return data;
    }

    @PostMapping("/save2")
    public User save(@RequestBody User user){
        user.setCreate_date(new Date());
        userMapper.save(user);
        return user;
    }

}
